package com.study.SellTicket;

import lombok.Data;

@Data
public class Ticket {
    private int  ticketNum;

    public int getTicketNum() {
        return ticketNum;
    }

    public void setTicketNum(int ticketNum) {
        this.ticketNum = ticketNum;
    }
    public  synchronized void sell(String name) throws InterruptedException {
            if(ticketNum > 0){
                Thread.sleep(100);
                this.ticketNum-=1;
                System.out.println(name + "售出一张票，余票："+this.ticketNum);
            }
    }
}
